package thread;

import java.util.Random;

public class test10 {
    public static long sum1;
    public static long sum2;
    public static int[] array=new int[10000000];
    static {
        Random random=new Random();
        for (int i = 0; i < 10000000; i++) {
            array[i]=random.nextInt(101);
        }
    }
    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(()->{
            for (int i = 1; i < 10000000; i+=2) {
                sum1+=array[i];
            }
        });
        Thread t2=new Thread(()->{
            for (int i = 0; i < 10000000; i+=2) {
                sum2+=array[i];
            }
        });
        t1.start();
        t1.join();
        t2.start();
        t2.join();
        System.out.println(sum1+sum2);
    }
}
